<!DOCTYPE html>
<html lang="en">
<head>
    <title>学生缴费</title>
    <#include "../inc/header.ftl"/>
    <link rel="stylesheet" href="${prefix}/assets/custom/css/main.css?20240428"/>
</head>

<body class="no-skin">

<div class="main-container ace-save-state" id="main-container">

    <div class="main-content">
        <div class="main-content-inner">

            <div class="page-content">
                <form id="studentForm" name="studentForm" method="post">
                    <input name="funds" type="hidden" id="funds" value=""/>
                    <table width="800" border="0" align="center" cellpadding="0" cellspacing="0" class="r_tablebr">
                        <tr>
                            <td valign="top" class="r_nr">
                                <table width="99%" border="0" cellspacing="0" cellpadding="0">
                                    <tr>
                                        <td class="r_title">河北省高校缴费通知书</td>
                                    </tr>
                                </table>
                                <table width="99%" border="0" cellpadding="0" cellspacing="0" class="r_zsdwbm">
                                    <tr>
                                        <td  align="left"><b>缴款码：</b>
                                            <input name="billnum" type="text" id="billnum" value="" class="r_input2" style="width:170px;" /></td>
                                        <td>交易流水号：<input type="text" id="bankaffirm" name="bankaffirm" value="" class="r_input2" style="width:170px;"></td>
                                    </tr>
                                </table>
                                <table width="99%" border="0" cellpadding="0" cellspacing="0" class="r_zsdwbm">
                                    <tr>
                                        <td width="30%" align="left">班级：
                                            <input name="classname" type="text" id="classname" style="width:150px" readonly="readonly" class="r_input" /></td>
                                        <td align="left">姓名：
                                            <input name="studentname" type="text" id="studentname" style="width:150px" readonly="readonly" class="r_input" /></td>
                                    </tr>
                                </table>
                                <table width="99%" border="1" cellpadding="0" cellspacing="1" class="r_jcxx4">
                                    <tr>
                                        <td width="100" align="center" bgcolor="#f0f0f0">收款银行</td>
                                        <td width="200" align="center" bgcolor="#f0f0f0"><input name="accountname" type="text" id="accountname" style="width:190px;" readonly="readonly" class="r_input" value="" /></td>
                                        <td width="100" align="center" bgcolor="#f0f0f0">缴费项目</td>
                                        <td width="120" align="center" bgcolor="#f0f0f0"></td>
                                        <td width="120" align="center" bgcolor="#f0f0f0"></td>
                                        <td width="120" align="center" bgcolor="#f0f0f0"></td>
                                    </tr>
                                    <tr>
                                        <td align="center" bgcolor="#f0f0f0">账　　号</td>
                                        <td align="center" bgcolor="#f0f0f0"><input name="accountcode" type="text" id="accountcode" style="width:190px;" readonly="readonly" value="" class="r_input" /></td>
                                        <td align="center" bgcolor="#f0f0f0">金　　额</td>
                                        <td align="center" bgcolor="#f0f0f0"></td>
                                        <td align="center" bgcolor="#f0f0f0"></td>
                                        <td align="center" bgcolor="#f0f0f0"></td>
                                    </tr>
                                    <tr>
                                        <td align="center" bgcolor="#f0f0f0">个人缴费号</td>
                                        <td align="center" bgcolor="#f0f0f0"><input name="payeraccount" type="text" id="payeraccount" style="width:190px;" readonly="readonly" value="" class="r_input" /></td>
                                        <td align="center" bgcolor="#f0f0f0">合　　计</td>
                                        <td colspan="3" align="center" bgcolor="#f0f0f0"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                                                <tr>
                                                    <td width="50%" bgcolor="#FFFFFF">（大写）<span id="vbigfunds"></span></td>
                                                    <td width="50%" bgcolor="#FFFFFF">（小写）<span id="vfunds"></span></td>
                                                </tr>
                                            </table></td>
                                    </tr>
                                </table>
                                <table width="99%" border="0" cellspacing="0" cellpadding="0">
                                    <tr>
                                        <td height="40" align="right" style="padding: 20px 0 10px;">
                                            <input type="button" name="button0" id="button0" onclick="queryStudentData()" class="r_button" value="查询单据" />&emsp;
                                            <input type="button" name="paybutton" id="paybutton" onclick="pay()" class="r_button" value="收款" />
                                        </td>
                                    </tr>
                                </table></td>
                        </tr>
                    </table>
                </form>
            </div><!-- /.page-content -->

        </div>
    </div><!-- /.main-content -->
</div><!-- /.main-container -->

<!-- basic scripts -->
<#include "../inc/basicjs.ftl"/>
<script src="${prefix}/assets/custom/js/commonview.js"></script>
<script type="text/javascript">
    var ischeck = false;
    //数据初始化
    function pay() {
        if(!ischeck) {
            alert("请先输入缴费编码，然后查询单据后再点击收款！");
            $("#billnum").focus();
            ischeck = false;
            return;
        }
        if($("#bankaffirm").val()=="") {
            $.messager.alert('提示', '请填写交易流水号！', 'info');
            return false;
        }

        $('#studentForm').form({
            url: prefix + '/view/student/studentpayview',
            onSubmit:function(){
                var isValid = $(this).form('validate');
                if (isValid){
                    $.messager.progress({
                        title: '提示',
                        msg: '数据处理中，请稍候……',
                        text: ''
                    });
                }
                return isValid;
            },
            success:function(data) {
                $.messager.progress('close');
                var data = eval('(' + data + ')');
                if(data.success) {
                    ischeck = false;
                    $.messager.alert('提示', data.msg, 'info', function() {
                        location = prefix + '/view/student/studentview';
                    });
                } else {
                    $('#paybutton').removeAttr("disabled");// 移除disabled属性
                    $.messager.alert('提示', "【" + data.code + "】" + data.msg, 'info');
                }
            }
        });
        $('#studentForm').submit();

    }

    function queryStudentData() {
        var state = [{"key":"0","value":"查询错误"},{"key":"1","value":"正常"},{"key":"2","value":"账户类型不符"},{"key":"3","value":"已收款"},{"key":"4","value":"票据不可用"},{"key":"5","value":"对账不成功，账户停用"},{"key":"6","value":"验签未通过"},{"key":"7","value":"该票据已超期"}];
        var billnum = $("#billnum").val();
        if(billnum=="") {
            $.messager.alert('提示', '请输入缴款码！', 'info');
            $("#billnum").focus();
            return;
        }
        $.messager.progress({
            title: '提示',
            msg: '正在获取票据，请稍候……',
            text: ''
        });
        $.ajax({
            type: "POST",
            url: prefix+"/view/student/querystudentview",
            dataType: "json",
            data: {billnum: billnum},
            success: function (dataOne) {
                $.messager.progress('close');
                if (!dataOne.success) {
                    $.messager.alert('提示', dataOne.msg, 'info');
                    return;
                }
                var bill = dataOne.data;
                if (bill.billstate == 3 || bill.billstate == 1) {
                    $("#payeraccount").val(bill.payeraccount);
                    $("#studentnum").val(bill.studentnum);
                    $("#studentname").val(bill.studentname);
                    $("#classname").val(bill.classname);
                    $("#accountname").val(bill.accountname);
                    $("#accountcode").val(bill.accountcode);
                    $("#funds").val(bill.funds);
                    $("#vfunds").html(bill.funds);
                    $("#vbigfunds").html(upDigit(bill.funds));
                }
                if (bill.billstate == 1) {
                    $('#paybutton').attr('disabled',false);
                    $('#billnum').attr("readonly","readonly");
                    ischeck = true;
                } else {
                    $('#paybutton').attr('disabled',true);
                    $.messager.alert('提示', dataOne.msgExt, 'info');
                } 
            }
        })
    }
</script>
</body>
</html>
